﻿
<%@ Page language="c#" Inherits="Mysoft.Crm.Application.Pages.Tools.FormEditor.Dialogs.Number" CodeBehind="Mysoft.Crm.Application.Pages.Tools.dll" %>
<%@ Register TagPrefix="cnt" Namespace="Mysoft.Crm.Application.Controls" Assembly="Mysoft.Crm.Application.Components" %>
<html>
<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312"/>
<title><%= dtProper %> Field Properties</title>
<link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
<link rel="stylesheet" type="text/css" href="/_common/styles/select.css">
<link rel="stylesheet" type="text/css" href="/_nav/tabs.css">
<link rel="stylesheet" type="text/css" href="/Tools/FormEditor/Styles/dialogs.css">
<script language="javascript" src="/_controls/settings.aspx"></script>
<script language="javascript" src="/_common/scripts/global.js"></script>
<script language="javascript" src="/Tools/FormEditor/Scripts/objects.js"></script>
<script language="javascript" src="/Tools/FormEditor/Scripts/fielddialogs.js"></script>
<script language="javascript" src="/Tools/FormEditor/Scripts/dialogs.js"></script>
<script language="javascript" src="/_controls/number/number.js"></script>
<script language="javascript">

	function window.onload()
	{
		var oField = window.dialogArguments.Field;
		
		InitializeDialog(oField);		
		
<%
		if (datatype != "integer")
		{
			formatFunc = "FormatFloat";
%>
			BuildAccuracy(oField.PropertyBag.Accuracy);
<%
		}
		else
		{
			formatFunc = "FormatInteger";
%>
			crmDialog.Accuracy.returnValue = 0;
<%
		}
%>

		crmDialog.MinValue.value		= AddFormatting(oField.PropertyBag.MinValue, <%= (datatype != "integer") ? "oField.PropertyBag.Accuracy" : "0" %>, ORG_NUMBER_FORMAT, false);
		crmDialog.MinValue.returnValue	= AddFormatting(oField.PropertyBag.MinValue, <%= (datatype != "integer") ? "oField.PropertyBag.Accuracy" : "0" %>, ORG_NUMBER_FORMAT, false);
		
		crmDialog.MaxValue.value		= AddFormatting(oField.PropertyBag.MaxValue, <%= (datatype != "integer") ? "oField.PropertyBag.Accuracy" : "0" %>, ORG_NUMBER_FORMAT, false);
		crmDialog.MaxValue.returnValue	= AddFormatting(oField.PropertyBag.MaxValue, <%= (datatype != "integer") ? "oField.PropertyBag.Accuracy" : "0" %>, ORG_NUMBER_FORMAT, false);
	}
			
	function BuildAccuracy(iAccuracy)
	{
		Accuracy.innerHTML = "<span name='Accuracy' class='selectBox' value='" + iAccuracy + "' changeHandler='CheckValue(crmDialog.MinValue);CheckValue(crmDialog.MaxValue);'><table cellspacing='0' cellpadding='2' style='display: none;'><tr><td val='0'>0</td></tr><tr><td val='1'>1</td></tr><tr><td val='2'>2</td></tr><tr><td val='3'>3</td></tr><tr><td val='4'>4</td></tr><tr><td val='5'>5</td></tr></table></span>";
	}


	function Ok()
	{
		if (!ValidateDisplayInfo())
		{
			return;
		}

		var iMinValue = StringToFloat(crmDialog.MinValue.returnValue);
		var iMaxValue = StringToFloat(crmDialog.MaxValue.returnValue);
		
		if (iMinValue >= iMaxValue)
		{
			alert( "The minimum value must be less than the maximum value." );
			
			return false;
		}

		var oField	= new FieldObj(
						crmDialog.TabName.returnValue,
						crmDialog.SectionName.returnValue,
						crmDialog.FieldName.value,
						crmDialog.FieldLocName.value,
						crmDialog.FieldDesc.value,
						crmDialog.DataType.value,
						(crmDialog.Required.value == "true"),
						crmDialog.OrgRequired.value,
						crmDialog.Span[0].checked,
						new Array(new LocalizedObj(crmDialog.DisplayName.value, ORG_LANGUAGE_CODE)),
						new Array(new LocalizedObj(crmDialog.Label.value, ORG_LANGUAGE_CODE)),
						null,
						null,
						new NumberPropertyBag(iMinValue, iMaxValue, parseInt(crmDialog.Accuracy.returnValue, 10), true)
					);

		window.returnValue = oField;

		window.close();
	}
	
	
	function CheckValue(o)
	{
		var sValue = <%= formatFunc %>(o.value, -100000000000, 100000000000, false, ORG_NUMBER_FORMAT<%= (datatype != "integer") ? ", parseInt(crmDialog.Accuracy.returnValue, 10)" : "" %>);
		
		if (!sValue)
		{
			o.select();
		}
		else
		{
			o.value			= <%= formatFunc %>(o.value, -100000000000, 100000000000, true, ORG_NUMBER_FORMAT<%= (datatype != "integer") ? ", parseInt(crmDialog.Accuracy.returnValue, 10)" : "" %>);
			o.returnValue	= sValue;
		}
	}

</script>
</head>
<body>
	<form name="crmDialog">
		<input type="hidden" name="DataType">
		<input type="hidden" name="Required">
		<input type="hidden" name="OrgRequired">
		<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
			<tr>
				<td class="header">
					<div class="header"><%= dtProper %>字段属性</div>
					<div class="headerdesc">修改<%= datatype %>字段属性。</div>
				</td>
			</tr>
			<tr>
				<td class="main">
					<table width="100%" height="100%" cellspacing="0" cellpadding="0">
						<tr height="25">
							<td>
								<cnt:AppTabBar id="crmTabBar" runat="server"/>
							</td>
						</tr>
						<tr>
							<td>
								<div id="tab0" class="tab" style="display: inline;">
									<fieldset>
										<legend><!-Display Name->显示名&nbsp;</legend>
										<div class="desc">
											<!-Specify the name to display in views, searching, and reporting.->指定在视图、检索和导出报表时显示的名称。
										</div>
										<table cellpadding="0" cellspacing="5" width="100%" style="table-layout: fixed;">
											<col width="50"><col>
											<tr>
													<td class="req"><!-Name->名称</td>
												<td><input name="DisplayName" type="text" maxlength="100"></td>
											</tr>
										</table>
									</fieldset>
									<br>
									<fieldset>
										<legend><!-Label->标识&nbsp;</legend>
										<div class="desc">
											<!-Specify the label for this field in forms.->指定本字段的标识
										</div>
										<table cellpadding="0" cellspacing="5" width="100%" style="table-layout: fixed;">
											<col width="50"><col>
											<tr>
												<td><!-Label->标识</td>
												<td><input name="Label" type="text" maxlength="100"></td>
											</tr>
										</table>
									</fieldset>
									<br>
									<fieldset>
										<legend><!-Location->提示&nbsp;</legend>
										<div class="desc">
											<!-Select the tab and section for this field to appear under. If a tab does not contain sections, it will not appear in the list.->
											选择要显示本字段的标签和区域；如果这个标签不包含区域，本字段将不能显示在列表中。
										</div>
										<div id="FieldLocations">
										</div>
									</fieldset>
								</div>
								<div id="tab1" class="tab">
									<fieldset>
										<legend><!-Layout->布局&nbsp;</legend>
										<div class="desc" style="padding-bottom: 5px;">
											<!-Select the number of columns the field occupies:->选择本字段所占的列的数目：
										</div>
										<table cellpadding="0" cellspacing="5" width="100%" style="table-layout: fixed;">
											<col width="15"><col><col width="85" style="text-align: right;">
											<tr>
												<td><input id="SpanTrue" name="Span" type="radio" class="radio"></td>
													<td><label for="SpanTrue"><!-Two columns->两列</label></td>
												<td>
													<table cellpadding="0" cellspacing="4" width="75" class="example">
														<tr>
															<td class="example">&nbsp;</td>
															<td class="example">&nbsp;</td>
														</tr>
														<tr>
															<td class="example active" colspan="2">&nbsp;</td>
														</tr>
														<tr>
															<td class="example">&nbsp;</td>
															<td class="example">&nbsp;</td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td colspan="3" height="10"></td>
											</tr>
											<tr>
												<td><input id="SpanFalse" name="Span" type="radio" class="radio"></td>
													<td><label for="SpanFalse"><!-One column->一列</label></td>
												<td>
													<table cellpadding="0" cellspacing="4" width="75" class="example">
														<tr>
															<td class="example">&nbsp;</td>
															<td class="example">&nbsp;</td>
														</tr>
														<tr>
															<td class="example active">&nbsp;</td>
															<td class="example">&nbsp;</td>
														</tr>
														<tr>
															<td class="example">&nbsp;</td>
															<td class="example">&nbsp;</td>
														</tr>
													</table>
												</td>
											</tr>
										</table>
									</fieldset>
									<br>

<%
									if (datatype != "integer")
									{
%>
										<br>
										<fieldset>
											<legend>精确度&nbsp;</legend>
											<div class="desc">
												指定小数点后精确到的位数。 例如: 5.325
											</div>
											<table cellpadding="0" cellspacing="5" width="100%" style="table-layout: fixed;">
												<col>
												<tr>
													<td id="Accuracy">
													</td>
												</tr>
											</table>
										</fieldset>
<%
									}
									else
									{
%>
										<input type="hidden" value="0" name="Accuracy">
<%
									}
%>
								</div>
								<div id="tab2" class="tab">
									<fieldset>
										<legend><!-Schema->显示&nbsp;</legend>
										<div class="desc">
											<!-Provide the following information for the metadata.->为元数据提供下列信息
										</div>
										<table cellpadding="0" cellspacing="5" width="100%" style="table-layout: fixed;">
											<col width="90"><col>
											<tr>
												<td><!-Field Name->字段名</td>
												<td><input name="FieldLocName" type="text" disabled></td>
											</tr>
											<tr>
												<td><!-Schema Name->显示名</td>
												<td><input name="FieldName" type="text" disabled></td>
											</tr>
											<tr>
												<td valign="top"><!-Description->描述</td>
												<td><textarea name="FieldDesc" rows="5" disabled></textarea></td>
											</tr>
										</table>
									</fieldset>
									<br>
									<fieldset>
										<legend><!-Required Level->要求级别&nbsp;</legend>
										<div class="desc">
											<!-Select the requirement level. If the field is system required, you cannot override it.->选择一个要求级别。如果本字段与系统有关联，你不能修改要求级别。
										</div>
										<table cellpadding="0" cellspacing="5" width="100%" style="table-layout: fixed;">
											<col>
											<tr>
												<td id="RequiredLevel">
												</td>
											</tr>
										</table>
									</fieldset>
								</div>
								<div id="tab3" class="tab">
									<fieldset>
										<legend>取值&nbsp;</legend>
										<div class="desc">
											指定本字段的取值范围。
										</div>
										<table cellpadding="0" cellspacing="5" width="100%" style="table-layout: fixed;">
											<col width="70"><col>
											<tr>
												<td class="req">最小值</td>
												<td><input name="MinValue" type="text" onblur="CheckValue(this);"></td>
											</tr>
											<tr>
												<td class="req">最大值</td>
												<td><input name="MaxValue" type="text" onblur="CheckValue(this);"></td>
											</tr>
										</table>
									</fieldset>
								</div>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td class="buttons">
					<button id="btnDialogOk" onclick="Ok();">确定</button>
					<span>&nbsp;</span>
					<button id="btnDialogCancel" onclick="Cancel();">取消</button>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
